import java.util.*;

public class BasisOefHashMap {

	
	public static void main(String[] args) {
		TreeMap<String,String> landen = new TreeMap<String,String>();
		
		landen.put("B", "Belgie");
		landen.put("NL", "Nederland");
		landen.put("F", "Frankrijk");
		landen.put("D", "Duitsland");
		landen.put("L", "Luxemburg");
		//landen.put(null, null);
		
		String eenLand = landen.get("F");
		System.out.println("Land met code F: "+eenLand);
		
		String vorigLand = landen.put("F", "Finland");
		System.out.println("Vorig land met code F: "+vorigLand);
		
		eenLand = landen.get("F");
		System.out.println("Land met code F: "+eenLand);
		
		System.out.println("\n*** View van de keys ");
		Iterator<String> it = landen.keySet().iterator();
		while(it.hasNext()){
			String landCode = it.next();
			eenLand = landen.get(landCode);
			System.out.println(landCode+" heeft als naam: "+eenLand);
			
		}
		System.out.println("\n*** View van de values ");
		it = landen.values().iterator();
		while(it.hasNext()){
			String landNaam = it.next();
			eenLand = landen.get(landNaam);
			System.out.println(landNaam);
			
		}
		
		System.out.println("\n*** View van de key-value paren");
		Iterator it2 = landen.entrySet().iterator();
		while(it2.hasNext()){
			System.out.println(it2.next());
			
		}
		
		//extra methods
		System.out.println("\n*** extra methods ***");
		System.out.println("Eerste key: "+landen.firstKey());
		System.out.println("Laaste key: "+landen.lastKey());
		
		SortedMap <String,String> landenSub = landen.subMap("D", "M");
		System.out.println("*** View van de key-value paren van de submap D-M ***");
		Iterator it3 = landenSub.entrySet().iterator();
		while(it3.hasNext()){
			System.out.println(it3.next());
		}
		
		

	}

}
